﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        $("#gridList").dataGrid({
            treeGrid: true,
            treeGridModel: "adjacency",
            ExpandColumn: "FClassNO",
            url: "/MainData/ItemsType/GetTreeGridJson",
            height: $(window).height() - 90,
            colModel: [
                { label: "主键", name: "FClassID", hidden: true, key: true },
                { label: '名称', name: 'FClassName', width: 200, align: 'left' },
                { label: '编号', name: 'FClassNO', width: 150, align: 'left' },
                { label: '排序', name: 'SortCode', width: 80, align: 'center' },
                {
                    label: "有效", name: "FEnabled", width: 60, align: "center",
                    formatter: function (cellvalue) {
                        return cellvalue == '1' ? "是" : "否";
                    }
                },
                { label: "备注", name: "FExplain", index: "F_Description", width: 200, align: "left" }
            ],
            rownumWidth: 40,
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增分类",
            url: "/MainData/ItemsType/Form",
            width: "450px",
            height: "380px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().FClassID;
        $.modalOpen({
            id: "Form",
            title: "修改分类",
            url: "/MainData/ItemsType/Form?keyValue=" + keyValue,
            width: "450px",
            height: "380px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/MainData/ItemsType/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().FClassID },
            success: function () {
                $("#gridList").resetSelection();
                $("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel" style="border: 0px;">
    <div class="search">
        <table>
            <tr>
                <td style="display:none">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>新建分类</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改分类</a></li>
                <li><a onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除分类</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <style>
        .ui-jqgrid {
            border-left: 0px;
            border-right: 0px;
            border-bottom: 0px;
        }
    </style>
</div>
